/**
 * Created by dell on 2017/7/20.
 */
abstract class Device{
    private String name;
    public abstract double getPrice();
    public Device(){}
    public Device(String name){
        this.name=name;
    }

    public String getName() {
        return name;
    }
}
public class AnonymousInner {
    public void test(Device d) {
        System.out.println("购买了一个：" + d.getName() + "，花掉：" + d.getPrice());
    }

    public static void main(String[] args) {
        AnonymousInner ai = new AnonymousInner();
        ai.test(new Device("电脑") {
            @Override
            public double getPrice() {
                return 50;
            }
        });
        Device d = new Device() {
            @Override
            public double getPrice() {
                return 567;
            }

            public String getName() {
                return "erewr";
            }

        };
        ai.test(d);
    }
}
